<template>
	<view class="content">
		
		<view class="flex" style="margin: 20rpx 0;color: #6F6F6F;padding: 20rpx;border-radius: 10rpx;">
			提现账户：当前微信零钱账户
		</view>
		
		<view style="padding: 40rpx 20rpx;background: #fff;border-radius: 30rpx; color:#333;text-align: center;">
			<view style="font-size: 28rpx; color: #333;text-align: left;margin-bottom: 60rpx;">请输入提现金额</view>
			<view style="margin-bottom: 60rpx;">
				<u--input prefixIcon="rmb" placeholder="请输入提现金额" border="surround" v-model="value" @input="zzs"></u--input>
			</view>
			<view class="flex" style="margin-bottom: 60rpx;">
				<view style="color: #8A8A8A;">当前余额：{{yue.balance}}派币=¥{{yue.qian}}</view>
				<view style="color: #007CFF;margin-left: 20rpx;" @click="value = yue.qian">全部提现</view>
			</view>
			<!-- <view class="flex" style="margin-bottom: 60rpx;">
				<view style="color: #8A8A8A;">手续费：{{shouxufei.toFixed(2)}}<span style="color:#248EFF;">（微信企业账户需支付千分之六的手续费）</span></view>
			</view> -->
			<view style="padding-bottom: 60rpx;" class="flexc">
				<view style="width: 300rpx;line-height: 100rpx;border: 1px #DFDFDF solid;border-radius: 20rpx; font-size: 32rpx;" @click="tixian">提现</view>
			</view>
		</view>
		<u-overlay :show="loading">
			<view class="flexcc" style="width: 100vw;height: 100vh;">
				<u-loading-icon color="#fff" text="加载中..." :vertical="true" textColor="#fff"></u-loading-icon>
			</view>
		</u-overlay>
		<u-toast ref="uToast2"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value:"",
				yue:"",
				loading:true
			}
		},
		onLoad() {
			this.getyue()
		},
		mounted() {
			
		},
		computed:{
			// shouxufei(){
			// 	return this.value * 0.006
			// }
		},
		methods: {
			tixian:function(){
				
				uni.$u.http.post(this.urlass + '/api/sport/api/live/user/cashout', {
					total:this.value,
					api_token: uni.getStorageSync('api_token')
				}).then(res => {
					if (res.data.msg.code == 0) {
						this.$refs.uToast2.show({
							message: "已申请提现",
						})
						this.loading = true
						this.getyue()
					} else {
						this.$refs.uToast2.show({
							message: res.data.msg.info,
							type: "error"
						})
					}
					
				})
			},
			getyue: function() {
				let data = {token: uni.getStorageSync('token')}
				this.yibuget('/api/v1/users/account2',data).then((res)=>{
					this.yue = res.data.data
					this.$set(this.yue,'qian',this.yue.balance/10)
					this.loading = false
				})
			},
			zzs:function(){
				if(this.value){
					let x = this.value.toString().replace(/[^0-9.]/g,'')
					if(x.indexOf(".") < 0 && x != "") { 
					        x = parseFloat(x);
					}else{
						let xx = x.split('.')[1].toString()
						console.log(xx)
						let xxx = xx.slice(0,1)
						x = x.split('.')[0]+'.'+xxx
					}
					if(x > this.yue.qian){
						x = this.yue.qian
					}
					this.$nextTick(item=>{
						this.value = x
					})
				}
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.content { background: #F9F9F9; padding: 20rpx; min-height: 100vh;
		/deep/ .uni-input{ line-height: 100rpx;height: 100rpx;}
		/deep/ .u-input__content__field-wrapper__field{line-height: 100rpx;height: 100rpx;}
		/deep/ .uicon-rmb span{ font-size: 60rpx;font-weight: bold;}
		/deep/ .uni-input-placeholder{ font-size: 40rpx;}
		/deep/ .uni-input-input{ font-size: 40rpx;}
		/deep/ .u-input{ background: #f5f5f5;}
	}
</style>
